/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package yoga.algo.phenotype;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/**
 *
 * @author Yogev Montekyo
 */
public class Population<T> implements Iterable<Individual<T>>
{
    private ArrayList<Individual<T>> m_arrayListGenotypes;

    public Population()
    {
        m_arrayListGenotypes = new ArrayList<Individual<T>>();
    }

    public Population(ArrayList<Individual<T>> listGenotypes)
    {
        m_arrayListGenotypes = (ArrayList<Individual<T>>) listGenotypes.clone();
    }
    
    public int size()
    {
        return m_arrayListGenotypes.size();
    }

    public Individual<T> get(int index)
    {
        return m_arrayListGenotypes.get(index);
    }
    
    public ArrayList<Individual<T>> toIndividualsList()
    {
        return (ArrayList<Individual<T>>) m_arrayListGenotypes.clone();
    }

    public void addRange(Collection<Individual<T>> genotypeCollection)
    {
        m_arrayListGenotypes.addAll(genotypeCollection);
    }

    public void add(Individual<T> genotype)
    {
        m_arrayListGenotypes.add(genotype);
    }

    public boolean remove(Individual<T> genotype)
    {
        return m_arrayListGenotypes.remove(genotype);
    }
    
    public void removeAll()
    {
        m_arrayListGenotypes.removeAll(m_arrayListGenotypes);        
    }

    @Override
    public Iterator<Individual<T>> iterator()
    {
        return m_arrayListGenotypes.iterator();
    }
        
}
